package com.senlingspace.system.service.impl;

import java.util.List;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.senlingspace.common.utils.DateUtils;
import com.senlingspace.common.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.senlingspace.system.mapper.SlkjStoreCostMarketingMapper;
import com.senlingspace.system.domain.SlkjStoreCostMarketing;
import com.senlingspace.system.service.ISlkjStoreCostMarketingService;

/**
 * 营销成本明细Service业务层处理
 * 
 * @author SenlingSpace
 * @date 2024-07-22
 */
@Service
public class SlkjStoreCostMarketingServiceImpl implements ISlkjStoreCostMarketingService 
{
    @Autowired
    private SlkjStoreCostMarketingMapper slkjStoreCostMarketingMapper;

    /**
     * 查询营销成本明细
     * 
     * @param id 营销成本明细主键
     * @return 营销成本明细
     */
    @Override
    public SlkjStoreCostMarketing selectSlkjStoreCostMarketingById(Long id)
    {
        return slkjStoreCostMarketingMapper.selectSlkjStoreCostMarketingById(id);
    }

    /**
     * 查询营销成本明细列表
     * 
     * @param slkjStoreCostMarketing 营销成本明细
     * @return 营销成本明细
     */
    @Override
    public PageInfo<SlkjStoreCostMarketing> selectSlkjStoreCostMarketingList(SlkjStoreCostMarketing slkjStoreCostMarketing, boolean pageFlag) {
        Page<Object> page = PageUtils.startPageExt(pageFlag);
        List<SlkjStoreCostMarketing> slkjStoreCostMarketings = slkjStoreCostMarketingMapper.selectSlkjStoreCostMarketingList(slkjStoreCostMarketing);
        long total = page.getTotal();

        PageInfo<SlkjStoreCostMarketing> pageInfo = new PageInfo<>(slkjStoreCostMarketings);
        pageInfo.setTotal(total);
        pageInfo.setPageNum(page.getPageNum());
        pageInfo.setPageSize(page.getPageSize());
        return pageInfo;
    }

    /**
     * 新增营销成本明细
     * 
     * @param slkjStoreCostMarketing 营销成本明细
     * @return 结果
     */
    @Override
    public int insertSlkjStoreCostMarketing(SlkjStoreCostMarketing slkjStoreCostMarketing)
    {
        slkjStoreCostMarketing.setCreateTime(DateUtils.getNowDate());
        return slkjStoreCostMarketingMapper.insertSlkjStoreCostMarketing(slkjStoreCostMarketing);
    }

    /**
     * 修改营销成本明细
     * 
     * @param slkjStoreCostMarketing 营销成本明细
     * @return 结果
     */
    @Override
    public int updateSlkjStoreCostMarketing(SlkjStoreCostMarketing slkjStoreCostMarketing)
    {
        slkjStoreCostMarketing.setUpdateTime(DateUtils.getNowDate());
        return slkjStoreCostMarketingMapper.updateSlkjStoreCostMarketing(slkjStoreCostMarketing);
    }

    /**
     * 批量删除营销成本明细
     * 
     * @param ids 需要删除的营销成本明细主键
     * @return 结果
     */
    @Override
    public int deleteSlkjStoreCostMarketingByIds(Long[] ids)
    {

        return slkjStoreCostMarketingMapper.deleteSlkjStoreCostMarketingByIds(ids);
    }

    /**
     * 删除营销成本明细信息
     * 
     * @param id 营销成本明细主键
     * @return 结果
     */
    @Override
    public int deleteSlkjStoreCostMarketingById(Long id)
    {
        return slkjStoreCostMarketingMapper.deleteSlkjStoreCostMarketingById(id);
    }
}
